package cn.codergege.demo.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/courses")
public class CourseController {

    @RequestMapping("/{department}")
    public Object getCourses(@PathVariable("department") String department) {
        List<String> courses = new ArrayList<>();
        if(department.equalsIgnoreCase("core")) {
            courses.add("c1");
            courses.add("c2");
            courses.add("c3");
        }
        if(department.equalsIgnoreCase("elective")) {
            courses.add("e1");
            courses.add("e2");
            courses.add("e3");
        }
        System.out.println("getCourses runs...");
        return courses;
    }
}
